<# 
Pester tests for Write-Logging
#>

. $PSCommandPath.tolower().Replace(".tests.ps1",".ps1")

Describe "basic Functionality" {
    it 'Command Test Write-Log' {
        Get-Command Write-Log | Select-Object -ExpandProperty Name | should be "Write-Log"
    }
    it 'Command Test Set-LogPath' {
        Get-Command Set-LogPath | Select-Object -ExpandProperty Name | should be "Set-LogPath"
    }
    it 'Command Test Get-LogPath' {
        Get-Command Get-LogPath | Select-Object -ExpandProperty Name | should be "Get-LogPath"
    }
    it 'Command Test Write-LogError' {
        Get-Command Write-LogError | Select-Object -ExpandProperty Name | should be "Write-LogError"
    }
    it 'Command Test Write-LogVerbose' {
        Get-Command Write-LogVerbose | Select-Object -ExpandProperty Name | should be "Write-LogVerbose"
    }
    it 'Command Test Write-LogWarning' {
        Get-Command Write-LogWarning | Select-Object -ExpandProperty Name | should be "Write-LogWarning"
    }
    it 'Command Test Write-LogDebug' {
        Get-Command Write-LogDebug | Select-Object -ExpandProperty Name | should be "Write-LogDebug"
    }
    it 'Command Test Write-LogHost' {
        Get-Command Write-LogHost | Select-Object -ExpandProperty Name | should be "Write-LogHost"
    }
    it 'Command Test Write-LogOnly' {
        Get-Command Write-LogOnly | Select-Object -ExpandProperty Name | should be "Write-LogOnly"
    }
    it 'Command Test Trace-Begin' {
        Get-Command Trace-Begin | Select-Object -ExpandProperty Name | should be "Trace-Begin"
    }
    it 'Command Test Trace-Process' {
        Get-Command Trace-Process | Select-Object -ExpandProperty Name | should be "Trace-Process"
    }
    it 'Command Test Trace-End' {
        Get-Command Trace-End | Select-Object -ExpandProperty Name | should be "Trace-End"
    }
}

Describe "Content Tests" {

    set-LogPath "TestDrive:\test.Log"

    BeforeEach { 
        if ( Test-Path "TestDrive:\test.Log") { Remove-Item "TestDrive:\test.Log" }
    } 

    it "hello WOrld SMS" {
        "Hello World" | Write-Log
        "TestDrive:\test.Log" | Should Contain "Hello World"
        "TestDrive:\test.Log" | Should Contain "\<\!\[LOG\[Hello World\]LOG\]\!\>"
        get-content "TestDrive:\test.Log" |write-host 
    }
    it "hello WOrld Basic" {
        "Hello World" | Write-Log -LogTypeBasic
        "TestDrive:\test.Log" | Should Contain "Hello World"
        "TestDrive:\test.Log" | Should not Contain "<![LOG[Hello World]LOG]!>"
        get-content "TestDrive:\test.Log" |write-host 
    }

}

